﻿namespace MyTSCharp
{
    internal class Program
    {
        /// <summary>
        /// Moving Game
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //Frist,int x,y is oridinal position
            int x = 0, y = 0;
            ConsoleKey input;
            do
            {
                //Output a string at position x,y
                Console.Clear();//清屏
                Console.SetCursorPosition(x, y);
                Console.Write(" ");
                //Get user input using console.ReadKey
                input = Console.ReadKey(true).Key;//input中放入你刚刚输入的键
                //change x,y accroding to user input
                switch (input)
                {
                    case ConsoleKey.A:
                        if (x > 0)
                            x--;
                        break;
                    case ConsoleKey.W:
                        if (y > 0)
                            y--;
                        break;
                    case ConsoleKey.D:
                        if (x < 80)//缓冲期的长度-句子长=限制
                            x++;
                        break;
                    case ConsoleKey.S:
                        if (y < 80)
                            y++;
                        break;
                    default:
                        break;
                }
            } while (input != ConsoleKey.Enter);//Go back to step 2
        }
    }
}